﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DataRole_Edit.aspx.cs" Inherits="SysManage_DataRole_Edit"　EnableEventValidation="false" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
 <title>数据角色编辑</title>
    <base target ="_self" />
    <link rel="stylesheet" href ="../css/css.css" type="text/css" />
    <!--#include file="../JS/KeyControlCode.js"-->
    <!--#include file="../JS/TrimData.js"-->
    <!--#include file="../JS/TDTextBoxControl.js"-->
     <script language="javascript" type="text/javascript">

       function showsub(theid)
       {  
          var thecurlayimg;
          thecurlayimg=theid+"img";    
          if(document.getElementById(theid).style.display=="none")
          {
             document.getElementById(theid).style.display="block";     
             document.images[thecurlayimg].src="image/jian.gif";       
          }
          else
          {
             document.getElementById(theid).style.display="none";
             document.images[thecurlayimg].src="image/jia.gif"; 
          }
       }
    </script>
    
    <script language="javascript" type="text/javascript">
       function Fieldshowsub(theid)
       {
          var thecurlayimg;
          thecurlayimg=theid+"img";    
          if(document.getElementById(theid).style.display=="none")
          {              
             document.getElementById(theid).style.display="block";     
             document.images[thecurlayimg].src="image/jian.gif";       
          }
          else
          {
            document.getElementById(theid).style.display="none";
            document.images[thecurlayimg].src="image/jia.gif"; 
          }
       }
    </script>
    <script language="javascript" type="text/javascript">

       //选择控件处理
       function CheckDataItem(DataItem)
       {
          var Item_ID=trim(DataItem.id);
          Item_ID=Item_ID.substring(8,Item_ID.length);
          if(document.getElementById(DataItem.id).checked==true)
          {
             document.form1.Item_IDList.value+=Item_ID+"^";            
          }
          else
          {
             var str;
             str=document.form1.Item_IDList.value;           
             var Index=str.indexOf(Item_ID);           
             var lstr=str.substring(0,Index);           
             var rstr=str.substring(Index+Item_ID.length+1,str.length);
             document.form1.Item_IDList.value=lstr+rstr;
          }
       }
    </script>
    <script language="javascript" type="text/javascript">
       //行按钮选择
        function RowRadioCheck(Ctrl)
        {       
            if(document.getElementById("DataRowCtrl").checked==true)
            {
               document.getElementById("DataRowView").style.visibility="visible";      
               document.getElementById("DataFieldView").style.visibility="hidden";              
            }
            else
            {              
               document.getElementById("DataRowView").style.visibility="hidden"; 
               document.getElementById("DataFieldView").style.visibility="visible";                  
            }                    
        }  
        
        //字段选择
        function FieldCheck(Field)
        {          
           var length=Field.id.length;           
           //var FieldID=Field.id.substr(5,7);          
           var str = document.form1.Field_IDList.value;
           if(document.getElementById(Field.id).checked==true)
           {
               //alert(Field.id);
               var aStr = Field.id.split('.');
               var sWrite  = aStr[0]+".W";
               var sRead   = aStr[0]+".R"; 
               var sHidden = aStr[0]+".H";               
               if(aStr[1]=="R")
               {                   
                   if(document.getElementById(sWrite).checked==true)
                   {
                       document.getElementById(sWrite).checked=false;
                       document.form1.Field_IDList.value = DelRepeatData(str,sWrite,"0");
                   }
                   if(document.getElementById(sHidden).checked==true)
                   {
                       document.getElementById(sHidden).checked=false;
                       document.form1.Field_IDList.value = DelRepeatData(str,sHidden,"0");
                   }
               }
               else if(aStr[1]=="W")
               {
                   if(document.getElementById(sRead).checked==true)
                   {
                       document.getElementById(sRead).checked=false;
                       document.form1.Field_IDList.value = DelRepeatData(str,sRead,"0");
                   }
                   if(document.getElementById(sHidden).checked==true)
                   {
                       document.getElementById(sHidden).checked=false;
                       document.form1.Field_IDList.value = DelRepeatData(str,sHidden,"0");
                   }                   
               }
               else 
               {
                   if(document.getElementById(sRead).checked==true)
                   {
                       document.getElementById(sRead).checked=false;
                       document.form1.Field_IDList.value = DelRepeatData(str,sRead,"0");
                   }
                   if(document.getElementById(sWrite).checked==true)
                   {
                       document.getElementById(sWrite).checked=false;
                       document.form1.Field_IDList.value = DelRepeatData(str,sWrite,"0");
                   }
               }
              document.form1.Field_IDList.value += Field.id + "^" ;              
           }
           else
           {              
              document.form1.Field_IDList.value = DelRepeatData(str,Field.id,"0");              
           }
        }
        
    //去掉重复的数据要比较的sObj,sID目标,是否选中
    function  DelRepeatData(sID,sObj,Ifchecked)
    {
       var sBack="";
       var sIDCol="";
       var aObj = sObj;
       if(sID != "")
       {
           var ary = sID.split('^');
           var iary = ary.length;
           for(x=0;x<ary.length;x++)
           {
               if(ary[x] != sObj )
               {
                   if(x!=0 && sIDCol !="")
                   {
                       sIDCol   = sIDCol + "^";
                   }
                   sIDCol   = sIDCol + ary[x];
               }
           }
       }
       return sIDCol
    }
    
        function SaveRowInfo()
        {
           
           if(form1.Role_Code.value == "")
           {
               alert("角色编码不能为空");
               return;
           }
           if(form1.Role_Name.value == "")
           {
               alert("角色名称不能为空");
               return;
           }
           //alert(form1.PageIDCol.value);
           form1.PageOrgPersIDCol.value = "";    //组织人员ID初始化
           form1.PageOrgPersNameCol.value = "";  //组织人员名称初始化
           
           form1.PageRoleIDCol.value = "";       //角色ID初始化
           form1.PageRoleNameCol.value = "";     //角色名称初始化

           var aPageID = form1.PageIDCol.value.split(',');
           for(i=0;i<aPageID.length-1;i++)
           {
             var sTemp = eval("form1.HChoiceID_"+aPageID[i]+".value") ;
             var sTemp2 = eval("form1.ChoiceName_"+aPageID[i]+".value") ;
             if(sTemp != "")
             {
               form1.PageOrgPersIDCol.value = form1.PageOrgPersIDCol.value + sTemp + "|"  ;
               form1.PageOrgPersNameCol.value = form1.PageOrgPersNameCol.value + sTemp2 + "|"  ;
             }
             
             var sTemp3 = eval("form1.HChoiceRoleID_"+aPageID[i]+".value") ;
             var sTemp4 = eval("form1.ChoiceRoleName_"+aPageID[i]+".value") ;
             if(sTemp3 != "")
             {
               form1.PageRoleIDCol.value = form1.PageRoleIDCol.value + sTemp3 + "|"  ;
               form1.PageRoleNameCol.value = form1.PageRoleNameCol.value + sTemp4 + "|"  ;
             }
           }

           //文档
           form1.PageFolderFileIDCol.value = "";       //文档ID初始化
           form1.PageFolderFileNameCol.value = "";     //文档名称初始化
           //debugger;
           var aPageDocID = form1.PageDocIDCol.value.split(',');
           for(i=0;i<aPageDocID.length-1;i++)
           {
                 var sTemp5 = eval("form1.HChoiceDocID_"+aPageDocID[i]+".value") ;
                 var sTemp6 = eval("form1.ChoiceDocName_"+aPageDocID[i]+".value") ;
                 if(sTemp5 != "")
                 {
                   form1.PageFolderFileIDCol.value = form1.PageFolderFileIDCol.value + sTemp5 + "|"  ;
                   form1.PageFolderFileNameCol.value = form1.PageFolderFileNameCol.value + sTemp6 + "|"  ;
                 }
           }
           
           var sallsave=window.document.getElementById("SaveInfo");
		   if(sallsave!=null)
		      sallsave.click();
        }
    </script>
</head>
<body>
<% 
  Response .ExpiresAbsolute=System.DateTime.Now. AddSeconds(-1);
  Response.Expires=0;
  Response.CacheControl = "no-cache";
%>
<form id="form1" method ="post"  runat="server">   
  <input type="hidden" id="HOrgIDCol" runat ="server"  />
  
  <input type="hidden"  id="Item_IDList" runat="server"/>
  <input type="hidden"  id="ItemNmae_IDList" runat="server"/>
  
  <input type="hidden" id="Field_IDList" runat="server"/>
  
  <input type="hidden" id="PageOrgPersIDCol" runat="server"/>
  <input type="hidden" id="PageOrgPersNameCol" runat="server"/>
  
  <input type="hidden" id="PageRoleIDCol" runat="server"/>
  <input type="hidden" id="PageRoleNameCol" runat="server"/>
  
  <input type="hidden" id="PageFolderFileIDCol" runat="server"/>
  <input type="hidden" id="PageFolderFileNameCol" runat="server"/>
  
  <input type="hidden" id="PageIDCol" runat="server" />
  <input type="hidden" id="PageDocIDCol" runat="server" />
  
  <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr> 
      <td width="15%" valign="top" style="background-image :url(../images/tablelb.gif); height:18px;" class="font13">
        <img height="18" src="../images/tablelbleft.gif" width="18" alt="" /></td>
      <td width="2%" valign="top" style="background-image :url(../images/tablelb.gif); background-color :#ffffff;" class="font13">
        <div align="right"><img height="18" src="../images/tablelbright.gif" width="12" alt="" /></div></td>
      <td colspan="2" valign="middle" bgcolor="#ffffff" class="font13"></td>
    </tr>
    <tr> 
      <td height="26" colspan="2" valign ="middle" style="background-color :#e9ecf5;" class="font13" align ="center" >数据角色编辑</td>
      <td width="80%" height="26" valign="bottom" style="background-image :url(../images/tddi.gif);" class="font13" align ="right"></td>
      <td width="3%" valign="top" style="background-image :url(../images/tddi.gif);" class="font13" align ="right" ><img  src="../images/tddir.gif" alt="" /></td>
    </tr>  
  </table>
  <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" style="background-color :#e9ecf5; ">
  <tr>
    <td style="height: 21px">
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="tablelsdi">
          <tr> 
            <td width="4%" style="background-image :url(../images/tablelb01.gif);"><img src="../images/tablelb01-left.gif" width="21" height="22" alt ="" /></td>
            <td width="82%" style="background-image :url(../images/tablelb01.gif);" class="font12w">数据角色编辑</td>
            <td width="14%" style="background-image :url(../images/tablelb01.gif);"> <div align="right"><img src="../images/tablelb01-right.gif" width="21" height="22" alt ="" /></div></td>
          </tr>
        </table>
    </td>
    </tr>
    <tr>
      <td>
       <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="tablelb">
          <tr style ="height :30px;">
            <td style="background-color :#E1EEFD; width :20%;" class="tableleft"  align ="right">角色编码:&nbsp;</td>
            <td  style="background-color :#E1EEFD; width :30%;" class="tableleft"><asp:TextBox ID="Role_Code" runat ="server" TabIndex ="1" MaxLength="20" Width="93px" onkeydown = "Number(this)" ></asp:TextBox><font color="red">*</font></td>
            <td style="background-color :#ECF4FD; width :15%;" class="tableleft" align ="right" >角色名称:&nbsp;</td>
            <td  style="background-color :#ECF4FD;" class="tableleft"><asp:TextBox ID="Role_Name" runat ="server" TabIndex ="2" MaxLength="20" ></asp:TextBox><font color="red">*</font></td>
          </tr>
          <tr>
            <td style="background-color :#ECF4FD;" class="tableleft" align ="right" >对应功能角色:&nbsp;</td>
            <td  style="background-color :#ECF4FD;" class="tableleft">
             <asp:DropDownList ID="Ctrl_Role"  DataValueField ="Code"  DataTextField ="Name" runat ="server" Width="157px" AutoPostBack="True" OnSelectedIndexChanged="Ctrl_Role_SelectedIndexChanged" ></asp:DropDownList><font color="red">*</font>
            </td>
　　　　    <td style="background-color :#E1EEFD; " class="tableleft"  align ="right" rowspan ="2">角色说明:&nbsp;</td>
　　　　    <td style="background-color :#E1EEFD;" class="tableleft" rowspan="2" align ="left" >
　　　　    <asp:TextBox ID="Role_Descr" TextMode="multiline" Rows = "3" Columns ="30" runat ="server" TabIndex ="2"></asp:TextBox>小于100字</td>
          </tr>
          <tr>
            <td style="background-color :#E1EEFD; height :30px; width :155px;" class="tableleft"  align ="right">是否有效:&nbsp;</td>
            <td  style="background-color :#ECF4FD; height: 31px;" class="tableleft"><asp:DropDownList ID="Effective" runat="server" Width="52px">
                <asp:ListItem Value="1">是</asp:ListItem>
                <asp:ListItem Value="0">否</asp:ListItem>
            </asp:DropDownList></td>
          </tr>
          <tr>
            <td  class="tableleft" colspan="4" style="height: 21px" >
              <div id="Ctrl">数据行控制<input type="radio" id="DataRowCtrl" name="RadioCtrl" runat ="server"   onclick="RowRadioCheck(this)" />&nbsp;字段控制<input type="radio" id="FieldCtrl" name="RadioCtrl"   onclick="RowRadioCheck(this)" runat="server"  /></div></td>       	      
          </tr>
      </table>
      </td>
      </tr>
      </table>
      <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" style="background-color :#e9ecf5; ">
         <tr>
           <td align="center" style="height: 21px">
              <asp:Button ID="SaveInfo" runat="server" Text="Button" Width="0px" Height="0px" OnClick="SaveInfo_Click" />   
              <input id="Submit11" type="button"  class="button02" value ="提交(s)" accesskey ="s" onclick ="SaveRowInfo()"/>
              &nbsp;&nbsp;
              <input type ="button" id="backBtn"  value ="返回(c)" accesskey ="c" class="button02" tabindex ="13" onclick ="window.close();" />         
           </td>
         </tr>
      </table>
      <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" style="background-color :#e9ecf5; ">
         <tr>
           <td style ="width :60%;" valign ="top" >
             <div id="DataFieldView" style="position:absolute;visibility:hidden;" runat ="server" ><%=sDataFieldHtml%></div>   
             <div id="DataRowView" style="position:absolute;" runat ="server"  ><%=sHtml%></div></td>           
          </tr>
          </table>
          <input type="hidden" id="hcline_Id" runat ="server"  />
          <input type="hidden" id="hidEditType" runat ="server" />
          <input type="hidden" id="Type" runat="server" />
          <input type="hidden" id="HRole_Code" runat="server" />
          <input type="hidden" id="HRole_Name" runat="server" />
          <input type="hidden" id="HCtrl_Role" runat="server" />
          
    </form>
        <script language ="javascript" type="text/javascript" >
    <!--
        var sData = dialogArguments;
        form1.hidEditType.value = sData.stype ;
        if(sData.stype == "2")  // 2 修改 1 新建
        {
          window.document.all.Ctrl_Role.disabled=true;
          
          var sobj = sData.RoleForm.Hcode.value; 
          var ary=sobj.split('~');
          form1.hcline_Id.value = trim(ary[0]); 
          form1.Role_Code.value = trim(ary[0]);
          form1.HRole_Code.value = trim(ary[0]);
          form1.Role_Name.value = trim(ary[1]); 
          form1.HRole_Name.value = trim(ary[1]); 
          form1.Role_Descr.value = trim(ary[2]);
          form1.Ctrl_Role.value = trim(ary[3]);
          form1.HCtrl_Role.value = trim(ary[3]);
          //form1.Creator_Role.value = trim(ary[4]);    
          form1.Effective.value=trim(ary[5]);
          form1.Field_IDList.value = trim(ary[6]);  //字段链表
          form1.Item_IDList.value=trim(ary[7]);     //组织授权
          form1.Type.value=1;
         
         //组织人员初始化
          var  sArray1 = document.form1.Item_IDList.value.split('|');
          var  sArray2 = trim(ary[8]).split('|');
          for(var i=0;i<sArray1.length;i++)
          {
            var aPoIDcol = sArray1[i].split('^');
            var str,str2;
            str=trim(aPoIDcol[0]);
            if(trim(str)!="")
            {
              //str="\""+ aPoIDcol[1] +"^" +aPoIDcol[2] + "\"" ;
              str="\""+ sArray1[i] + "\"" ;
              str2="\""+ sArray2[i] + "\"" ;
              //eval("form1.HChoiceID_"+aPoIDcol[0]+".value") ;
               if(str == '^')
              str="";
              if(str2 == '^')
              str2="";
              
              var str4 = "HChoiceID_"+aPoIDcol[0] ;
              if(document.getElementById(str4)!=null)
              {              
              eval("form1.HChoiceID_"+aPoIDcol[0]+".value = "+str) ;
             
              }
              
              var str5 = "ChoiceName_"+aPoIDcol[0] ;
              if(document.getElementById(str5)!=null)
              {              
             
              eval("form1.ChoiceName_"+aPoIDcol[0]+".value = "+str2) ;
              }
              //eval("form1.NewPersID"+iNo+".value=\""+cPersID+"\";");
              //eval(\"form1.ChoiceName_\"+sPageInfo+\".value=\"+ChoiceNameInfo+\";\");
              //document.getElementById(str).checked=true;
            }
          }
          
          //角色初始化
          var  sArray3 = ary[9].split('|');
          var  sArray4 = ary[10].split('|');
          for(var m=0;m<sArray3.length-1;m++)
          {
            var aPoIDcol = sArray3[m].split('^');
            var str,str2;
            str=trim(aPoIDcol[0]);
            if(trim(str)!="")
            {
              str="\""+ sArray3[m] + "\"" ;
              str2="\""+ sArray4[m] + "\"" ;
              if(str == '^')
              str="";
              if(str2 == '^')
              str2="";
              
              var str4 = "HChoiceRoleID_"+aPoIDcol[0] ;
              if(document.getElementById(str4)!=null)
              { 
              eval("form1.HChoiceRoleID_"+aPoIDcol[0]+".value = "+str) ;
              }
              
              var str5 = "ChoiceRoleName_"+aPoIDcol[0] ;
              if(document.getElementById(str5)!=null)
              {
              eval("form1.ChoiceRoleName_"+aPoIDcol[0]+".value = "+str2) ;
              }
            }
          }

           //文档初始化
          var  sArray5 = ary[11].split('|');
          var  sArray6 = ary[12].split('|');
          for(var p=0;p<sArray5.length-1;p++)
          {
            var aPoIDcol = sArray5[p].split('^');
            var str,str2;
            str=trim(aPoIDcol[0]);
            if(trim(str)!="")
            {
              str="\""+ sArray5[p] + "\"" ;
              str2="\""+ sArray6[p] + "\"" ;
              if(str == '^')
                  str="";
              if(str2 == '^')
                  str2="";
              
              var str4 = "HChoiceDocID_"+aPoIDcol[0] ;
              if(document.getElementById(str4)!=null)
              { 
                  eval("form1.HChoiceDocID_"+aPoIDcol[0]+".value = "+str) ;
              }
              
              var str5 = "ChoiceDocName_"+aPoIDcol[0] ;
              if(document.getElementById(str5)!=null)
              {
              eval("form1.ChoiceDocName_"+aPoIDcol[0]+".value = "+str2) ;
              }
            }
          }
          
          //字段初始化
          //alert(form1.Field_IDList.value);
          var  sArray2 = document.form1.Field_IDList.value.split('^');
          for(var j=0;j<sArray2.length;j++)
          {
             var str;
             str=trim(sArray2[j]);
             if(trim(str)!="")
             {
               //str="Field"+str;   
               if(document.getElementById(str)!=null)
                   document.getElementById(str).checked=true;
             }
          }
        }
       -->
        </script>
    
 </body>
</html>
